package com.app.micaihu.custom.components;


import android.text.TextUtils;

import java.net.URLEncoder;
import java.util.HashMap;

/**
 * Created by Guo on 2016/8/4.
 * <p>
 * HashMap的包装类,将所有put的value进行utf-8的编码
 */
public class ParamMap extends HashMap<String, String> {

    public String putEncode(String key, String value) {
        if (TextUtils.isEmpty(value)) {
            return super.put(key, value);
        }
        String encodeVal;
        try {
            encodeVal = URLEncoder.encode(value, "utf-8");
        } catch (Exception e) {
            e.printStackTrace();
            encodeVal = "";
        }
        return super.put(key, encodeVal);
    }

}